<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../vue.js"></script>
    <style>
        .active{
            background: red;
        }
    </style>
</head>
<body>
    <div id="box">
        <ul>
            <li v-for="item,index in list" :class="current===index?'active':''"
                @click="handleClick(index)">
                {{item}}  {{index}}
            </li>
        </ul>
    </div>
</body>
<script>
    var obj = {
        data() {
            return {
                list:["aa","bb","cc","dd"],
                current: 0,//当前点击的索引
            }
        },
        methods:{
            handleClick(index){
                this.current = index
            }
        }
    }
    var app = Vue.createApp(obj).mount("#box")
</script>
</html>